package com.zzyl.mapper;

import com.zzyl.entity.NursingPlan;
import com.zzyl.entity.NursingProject;
import com.zzyl.entity.NursingProjectPlan;
import com.zzyl.vo.NursingPlanVo;
import com.zzyl.vo.NursingProjectPlanVo;
import com.zzyl.vo.NursingProjectVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface NursingPlanMapper {

    @Select("select * from nursing_plan")
    List<NursingPlanVo> getAll();

    @Insert("INSERT INTO nursing_plan (sort_no, plan_name, status, create_time, update_time, create_by, update_by, remark)\n" +
            "        VALUES (#{sortNo}, #{planName}, #{status}, #{createTime}, #{updateTime}, #{createBy}, #{updateBy}, #{remark})")
    @Options(keyProperty = "id",useGeneratedKeys = true)
    void add(NursingPlan nursingPlan);

    List<NursingPlanVo> page(String name,Integer status);

    @Select("select * from nursing_plan where id = #{id}")
    NursingPlan getById(Integer id);

    void update(NursingPlan nursingPlan);

    void updateMiddle(NursingProjectPlanVo nursingProjectPlanVo);

    // @Delete("delete from nursing_project_plan where project_id = #{projectId}")
    // void deleteMiddle(Long projectId);
    //
    // void insertMiddle(NursingProjectPlanVo nursingProjectPlanVo);

    @Delete("delete from nursing_plan where id = #{id}")
    void deleteById(Integer id);

    @Update("update nursing_plan set status = #{status} where id = #{id}")
    void updateStatus(Integer id, Integer status);

    @Select("select np.name projectName,npp.* from nursing_project_plan npp left join nursing_project np on npp.project_id = np.id where npp.plan_id = #{id}")
    List<NursingProjectPlanVo> getList(Integer id);

    void addMiddle(NursingProjectPlanVo npp);
}
